<%+cbi/valueheader%>
<script type="text/javascript">
	$(document).ready(function(){
		var regObj = $("#cbid\\.lorasrv\\.lorasrv\\.band");
		var Rx2DrObj = $("#cbid\\.lorasrv\\.lorasrv\\.Rx2Datarate");

		function appendRx2Dr(rx2dr){
			Rx2DrObj.html("");
			var rxDrList;
			var region = regObj.val();

			if( !rx2dr || rx2dr < 0 ){
				rx2dr = eval(region + "_RX2_DR");
			}

			if( region == "US915" || region == "AU915" ){
				rxDrList = eval(region + "_RX_DR");
			}
			else{
				rxDrList = eval(region + "_DR");
			}
			rxDrList.forEach(function(v,i){
				var text;
				var dr = eval(region + "_DR_SF")[v];
				var bw = eval(region + "_DR_BW")[v];
				if( dr <= 12 ){
					text = "SF" + dr + "BW" + ( bw / 1000);
				}
				else if( dr > 12 ){
					text = "FSK" + dr + "Kbps"
				}

				Rx2DrObj.append("<option value='"+v+"'>DR_"+v+" "+text+"</option>")
			});
			Rx2DrObj.val(rx2dr);
		}

		
		appendRx2Dr(<%=tostring(self:cfgvalue(section) or self.default)%>)
		regObj.change(function(){
			appendRx2Dr();
		});
	});
</script>
<select class="cbi-input-select" onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>>
<% for i, key in pairs(self.keylist) do -%>
	<option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr(tostring(self:cfgvalue(section) or self.default) == key, "selected", "selected") %>><%=striptags(self.vallist[i])%></option>
<%- end %>
</select>
<%+cbi/valuefooter%>